/**
 * 
 */
package com.hibernate.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;

/**
 * @author lijt
 *
 */
@Entity
@Table(name = "API_LOG")
public class ApiLog extends BaseEntity implements Serializable {

	private static final long serialVersionUID = -6581249769239902461L;
	
	public ApiLog() {
		
	}
	
	private Long id;
	@NotNull
	private Long userId;
	@Length(max=20)
	private String ip;
	@NotNull
	private Date time;	
	@NotNull @Length(max=100)
	private String className;
	@NotNull @Length(max=50)
	private String methodName;
	@Length(max=1000)
	private String mainArgs;
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "USER_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	
	@Column(name = "IP", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	
	@Column(name = "TIME", unique = false, nullable = false, insertable = true, updatable = true)
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	
	@Column(name = "CLASS_NAME", unique = false, nullable = false, insertable = true, updatable = true, length=100)
	public String getClassName() {
		return className;
	}
	public void setClassName(String className) {
		this.className = className;
	}
	
	@Column(name = "METHOD_NAME", unique = false, nullable = false, insertable = true, updatable = true, length=50)
	public String getMethodName() {
		return methodName;
	}
	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}
	
	@Column(name = "MAIN_ARGS", unique = false, nullable = false, insertable = true, updatable = true, length=1000)
	public String getMainArgs() {
		return mainArgs;
	}
	public void setMainArgs(String mainArgs) {
		this.mainArgs = mainArgs;
	}	
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return "ApiLog";
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return getId();
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return "API_LOG" + getId();
	}
	
}
